import pandas as pd
import sys
import os

csv_path = './csv'
# 生成资源文件目录访问路径
def resource_path(relative_path):
    if getattr(sys, 'frozen', False):  # 是否Bundle Resource
        base_path = sys._MEIPASS
    else:
        base_path = os.path.abspath(".")
    return os.path.join(base_path, relative_path)


# 访问res文件夹下a.txt的内容
filename = resource_path(os.path.join("file", "csv", "chili.xlsx"))
print('filename', filename)
with open(filename, 'rb') as f:
    lines = f.readlines()
    print(lines)
    f.close()


class FileContext:

    def __init__(self):
        # self._chili = pd.read_excel(resource_path(os.path.join('/csv/chili.xlsx')), engine='openpyxl')

        self._chili = pd.read_excel(resource_path(os.path.join("file", "csv", "chili.xlsx")), engine='openpyxl')
        self._pepper = pd.read_excel(resource_path(os.path.join("file", "csv", "chili.xlsx")), engine='openpyxl')

    def get_chili(self):
        return self._chili

    def get_pepper(self):
        return self._pepper

#
# if __name__ == '__main__':
#     print(FileContext().get_chili())
